<ui:composition template="/WEB-INF/templates/login-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:param name="pageName" value="Approve Asset Request" />
	<ui:define name="menu"></ui:define>
	<ui:define name="submenu"></ui:define> 
	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>
	<ui:define name="content">	
		 
		<h:outputText value="Asset Request Form" styleClass="outputTextTitle"/>	
		<h:form> 
		 <p:growl/> 
		 
		 <p:panel header="Employee Details"> 
		   <h:panelGrid columns="6" cellspacing="8" columnClasses="employeeDetailLabel,gridCellMiddleLeftAligned, employeeDetailText, employeeDetailLabel,gridCellMiddleLeftAligned, employeeDetailText" >
		          
           <h:outputLabel value="Asset Code" />
           <h:outputLabel value=":" />
           <h:outputText value="#{approveAssetRequestBean.assetRequest.assetReferenceCode}" />
           
           <h:outputLabel value="Request Date" />
           <h:outputLabel value=":" />
           <h:outputText value="#{approveAssetRequestBean.assetRequest.requestDate}" >
           		<f:convertDateTime pattern="dd-MMM-yyyy HH:mm a" timeZone="#{approveAssetRequestBean.timeZone}"/> 
           </h:outputText>

           <h:outputLabel value="Employee Name " />
           <h:outputLabel value=":" />
           <h:outputText value="#{approveAssetRequestBean.assetRequest.employee.firstName} #{approveAssetRequestBean.assetRequest.employee.lastName}" />
		              
           <h:outputLabel value="Recommended By" />
           <h:outputLabel value=":" />
           <h:outputText value="#{approveAssetRequestBean.assetRequest.recommendedBy.firstName} #{approveAssetRequestBean.assetRequest.recommendedBy.lastName}" />

           <h:outputLabel value="Approved By " />
           <h:outputLabel value=":" />
           <h:outputText value="#{approveAssetRequestBean.assetRequest.approvedBy.firstName} #{approveAssetRequestBean.assetRequest.approvedBy.lastName}"  />
           
           <h:outputLabel value="System Administrator" />
           <h:outputLabel value=":" />
           <p:selectOneMenu id="SystemAdministrator" value="#{approveAssetRequestBean.selectedSysAdmin}" style="width:150px;" >  
				<f:selectItems value="#{approveAssetRequestBean.systemAdminsMap}" />   
	       </p:selectOneMenu>
           
          </h:panelGrid>
          </p:panel>
           
          <p:panel header="Asset Details">            
           
           <p:dataTable  value="#{approveAssetRequestBean.assetDetailsList}" var="newAsset" >   
  
		            <p:column headerText="Asset Type"> 
		              	<h:outputText value="#{newAsset.assetType}" />                 
		            </p:column>  
		  
		            <p:column headerText="Required On"> 
		              	<h:outputText value="#{newAsset.requiredDate}" > 
		              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{approveAssetRequestBean.timeZone}"/>
		              	</h:outputText> 	               
		            </p:column>  
		            
		            <p:column headerText="Return Date"> 
		              	<h:outputText value="#{newAsset.expectedReturnDate}" >
		              		<f:convertDateTime pattern="dd-MMM-yyyy" timeZone="#{approveAssetRequestBean.timeZone}"/>
		              	</h:outputText>                  
		            </p:column>  
		            
		            <p:column headerText="Purpose"> 
		              	<h:outputText value="#{newAsset.purpose}" />  	               
		            </p:column>  
		            
		            <p:column headerText="Remarks"> 
		              	<h:outputText value="#{newAsset.remarks}" />                 
		            </p:column>  
		            
		            <p:column headerText="Status"> 
		              	<p:selectOneMenu value="#{newAsset.assetStatus}">			              	   					   
							<f:selectItem  itemValue="APPROVED" itemLabel="APPROVE"/>
							<f:selectItem  itemValue="REJECTED" itemLabel="REJECT"/>
			            </p:selectOneMenu>             
		            </p:column>
			       
          </p:dataTable>
          
          <h:outputLabel value="Your Comments" style="font-weight:bold;"/>
                <h:panelGrid rendered="#{approveAssetRequestBean.activity eq 'byRecommender'}">
             	    <p:inputTextarea id="recommenderComments" style="width:560px;" rows="3" value="#{approveAssetRequestBean.assetRequest.recommenderComments}"/>
             		<p:watermark for="recommenderComments" value="Recommender Comments..." />  
             	</h:panelGrid>
             	
             	<h:panelGrid rendered="#{approveAssetRequestBean.activity eq 'byApprover'}">
	             	<h:panelGroup>
		             	<h:outputText value="Recommender Comments :" style="font-weight:bold;" />
		             	<font face="comic sans MS, new york, times" size="2"><b>#{approveAssetRequestBean.assetRequest.recommenderComments} </b></font>
	             	</h:panelGroup>
	             	<p:inputTextarea id="approverComments" style="width:560px;" rows="3" value="#{approveAssetRequestBean.assetRequest.approverComments}"/>
	             		<p:watermark for="approverComments" value="Approver Comments..." />
	            </h:panelGrid>  
          </p:panel> 

          
        <h:panelGrid style="padding-top: 5px; width: 100%; border-top: 1px solid #d9d9d9" columnClasses="gridCellMiddleRightAligned">
			  <h:panelGroup rendered="#{approveAssetRequestBean.activity eq 'byRecommender' and (approveAssetRequestBean.assetRequest.recommenderStatus  eq 'IN PROCESS')}">
		           <p:commandButton id="RECOMMEND" value="RECOMMEND" actionListener="#{approveAssetRequestBean.recommenderRecommendListener}" update="@form"  />
		           <p:commandButton id="recommender" value="REJECT / SEND FOR MODIFICATIONS" actionListener="#{approveAssetRequestBean.rejectListener}" update="@form" />
		           <p:commandButton value="BACK" onclick="history.back();"  rendered="#{approveAssetRequestBean.renderBackButton}" /> 		           
	          </h:panelGroup>
	          
	          <h:panelGroup rendered="#{approveAssetRequestBean.activity eq 'byApprover' and (approveAssetRequestBean.assetRequest.approverStatus  eq 'IN PROCESS')}">
             		<p:commandButton value="APPROVE" actionListener="#{approveAssetRequestBean.approveListener}" update="@form"/> 
		        	<p:commandButton id="approver" value="REJECT/ SEND FOR MODIFICATIONS" actionListener="#{approveAssetRequestBean.rejectListener}" update="@form"/>
		        	<p:commandButton value="BACK" onclick="history.back();"  rendered="#{approveAssetRequestBean.renderBackButton}" />		
             </h:panelGroup>    
		</h:panelGrid>
		 
		<h:panelGrid rendered="#{approveAssetRequestBean.assetRequest.recommenderStatus  ne 'IN PROCESS' and  (approveAssetRequestBean.activity eq 'byRecommender')}">
		      <h:outputLabel value="This asset request has been #{approveAssetRequestBean.assetRequest.recommenderStatus} ." styleClass="outputLabelwamInformation" />
		      <p:commandButton value="Back" onclick="history.back();"  rendered="#{approveAssetRequestBean.renderBackButton}" />
		</h:panelGrid>
		<h:panelGrid rendered="#{approveAssetRequestBean.assetRequest.approverStatus  ne 'IN PROCESS' and  (approveAssetRequestBean.activity eq 'byApprover')}">
		      <h:outputLabel value="This asset request has been #{approveAssetRequestBean.assetRequest.approverStatus} ." styleClass="outputLabelwamInformation" />
		      <p:commandButton value="Back" onclick="history.back();"  rendered="#{approveAssetRequestBean.renderBackButton}" />
		</h:panelGrid>
		
		
         
     </h:form>
	</ui:define>
	
</ui:composition>
